package cn.lds.j375.healthexam.service.impl;

import cn.lds.j375.healthexam.entity.HealthExamPackage;
import cn.lds.j375.healthexam.dto.ResultDTO;
import cn.lds.j375.healthexam.exception.SysException;
import cn.lds.j375.healthexam.mapper.HealthExamPackageMapper;
import cn.lds.j375.healthexam.service.HealthExamPackageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.Objects;

@Service
public class HealthExamPackageServiceImpl implements HealthExamPackageService {

    @Autowired
    private HealthExamPackageMapper healthExamPackageMapper;

    @Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
    @Override
    public ResultDTO<List<HealthExamPackage>> selectHealthExamPackageAll() {


        List<HealthExamPackage> healthExamPackages = healthExamPackageMapper.selectList(null);

        if (CollectionUtils.isEmpty(healthExamPackages)){

        }


        return ResultDTO.buildSuccess(healthExamPackages);
    }

    @Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
    @Override
    public ResultDTO<HealthExamPackage> selectHealthExamPackageById(Integer id) throws SysException {

        HealthExamPackage healthExamPackage = healthExamPackageMapper.selectHealthExamItemById(id);

        if (Objects.isNull(healthExamPackage)){
            throw new SysException(ResultDTO.buildError("没有查询到内容"));
        }


        return ResultDTO.buildSuccess(healthExamPackage);
    }

    @Override
    public ResultDTO addHealthExamPackage(HealthExamPackage healthExamPackage) {






        return null;
    }

    @Override
    public ResultDTO modifyHealthExamPackage(HealthExamPackage healthExamPackage) {
        return null;
    }

    @Override
    public ResultDTO removeHealthExamPackage(Integer id) {
        return null;
    }
}
